<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]-->
    <script type="text/javascript" src="../../../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../../../lib/respond.min.js?rev=@@hash"></script>
    <!--[endif]-->
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../../../../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../../../../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="../../../../ht-css/Project.css" />
    <link rel="stylesheet" type="text/css" href="../../../../ht-css/style-q.css" />
    <!--[if IE 6]-->
    <script type="text/javascript" src="../../../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <!--[endif]-->
    <title>新増安卓补丁包</title>
</head>
<body>
<nav class="breadcrumb">首页 <span class="c-gray en">&gt;移动端管理 <span class="c-gray en">&gt;</span> <span onclick="returnVer()" style="cursor: pointer">安卓补丁包管理</span><span class="c-gray en">&gt;</span> 新増<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px ;display:block" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<article class="page-container">
    <form class="ml-20 mr-20" id="appVersionForm"  method="post">
        <div class="bk-gray bg-1 pd-20 text-c">
            <table class="table mt-10 col-2-1" style="margin-left: 35%">
                <tbody>
                <tr>
                    <td>
                        <div>
                            <label class="form-label f-l w-85 text-r lh-26"><em class="c-red mr-5">*</em>补丁版本号：</label>
                            <input type="text" class="input-text radius f-l ml-10" id="patchVersionCode" name="versionCode" style="width: 60%"  oninput = "value=value.replace(/[^\d]/g,'')" autocomplete="off">
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>
                        <div>
                            <label class="form-label f-l w-85 text-r lh-26"><em class="c-red mr-5">*</em>补丁包名称：</label>
                            <input type="text" class="input-text radius f-l ml-10" id="patchVersionName" name="fileName" style="width: 60%"   autocomplete="off">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div>
                            <label class="form-label f-l w-85 text-r lh-26"><em class="c-red mr-5">*</em>APP版本号：</label>
                           <span><input type="radio" class="f-l  ml-10" value="" checked id="appVersionCoderadio" style="margin-top: 4px;display: none"><span class="f-l " id="appVersionCode"></span></span>
                            <input type="button" class="btn  radius size-S" value="请选择" onclick="appversionnumber()"><br>
                            <span style="margin-left: -230px;">注：此为需要补丁包对应的app版本号选择</span>
                        </div>
                    </td>
                </tr>
                <tr>
                <tr>
                    <td>
                        <div style="width: 642px;">
                            <label class="form-label f-l w-85 text-r lh-26"><em class="c-red mr-5">*</em>更新内容：</label>
                            <textarea style="width: 539px;" class="textarea"  id="content"  placeholder="请填写内容.." onkeyup="this.value = this.value.substring(0,200)"></textarea><br>
                            <span style="margin-left: -350px;">注：最多200个字符</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div>
                            <label class="form-label f-l w-85 text-r lh-30" style="height:26px"><em class="c-red mr-5">*</em>状态：</label>
                            <span class="select-box size-M ml-10 f-l" style="width:40%">
                                    <select class="select" name="isOn" id="status">
                                        <option value="">请选择</option>
                                        <option value="10">开启</option>
                                        <option value="20">关闭</option>
                                    </select>
                                </span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div>
                            <label class="form-label f-l w-85 text-r lh-26"><em class="c-red mr-5">*</em>上传补丁包：</label>
                            <input type="button" class="btn f-l  ml-10  radius size-S" onclick="addAndroid()" value="添加最新的android包">
                            <input type="text"  class="input-text f-l radius" style="width:75%;display: none" id="appApkPath" >
                            <br>
                            <span style="margin-left: -151px;margin-top: 12px;" id="appApkPathnames"  class="f-l ml-10"></span>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>

            <div class="text-c mt-10">
                <input type="button" class="btn btn-secondary radius size-S" value="确认" onclick="save()">
                <input type="button" class="btn radius size-S ml-10" value="取消" onclick="returnVer()">
            </div>
        </div>
    </form>
    <!--添加最新android包弹窗-->
    <div id="add-android" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="ture" style="border-radius: 8px;">
        <div class="modal-dialog" style="top:50%;margin-top:-100px">
            <div class="modal-content radius" style="height:200px;width:540px;">
                <div class="modal-header"  >
                    <a class="close" style="margin-right: 5px;width: 22px;height: 22px;margin-top: 5px" data-dismiss="modal" aria-hidden="true" >×</a>
                </div>
                <form id="appApkForm" method="post" enctype="multipart/form-data">
                    <div class="mt-10 pl-20">
                            <span class="btn-upload form-group">
                                <input class="input-text upload-url radius mr-10" type="text" name="appApkName" id="appApkName" style="margin-top:2px;height: 27px;" readonly>
                                <input type="button" class="btn btn-secondary btn-upload size-S radius"  value="选择文件">
                                <input type="file" id="appApkFile" name="file" style="margin-top:2px" class="input-file">
                                <!--上传路径-->
                                <input type="hidden" name="catalog" value="12">
                            </span>
                    </div>
                    <div class="mt-40 text-c">
                        <input type="submit" class="btn btn-secondary size-S radius ml-10" id="uploadAppApk" value="确&nbsp;&nbsp;定">
                        <input type="button" class="btn size-S radius ml-10" value="取&nbsp;&nbsp;消" onclick="closeSelect()">
                    </div>
                </form>

            </div>
        </div>
    </div>

    <!--上传成功弹窗-->
    <div id="upload-success" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="ture" style="border-radius: 8px;">
        <div class="modal-dialog" style="top:50%;margin-top:-100px">
            <div class="modal-content radius" style="height:200px;width:540px;">
                <div class="modal-header" style="border-bottom: none">
                    <a class="close" style="margin-right: 5px;width: 22px;height: 22px;margin-top: 5px" data-dismiss="modal" aria-hidden="true" >×</a>
                </div>
                <div class="text-c f-24" style="height:120px;line-height: 120px"><b>上传成功</b></div>
            </div>
        </div>
    </div>
    <!--上传成功弹窗end-->

    <!--上传失败弹窗-->
    <div id="upload-defate" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="ture" style="border-radius: 8px;">
        <div class="modal-dialog" style="top:50%;margin-top:-100px">
            <div class="modal-content radius" style="height:200px;width:540px;">
                <div class="modal-header" style="border-bottom: none">
                    <a class="close" style="margin-right: 5px;width: 22px;height: 22px;margin-top: 5px" data-dismiss="modal" aria-hidden="true" >×</a>
                </div>
                <div class="text-c f-24" style="height:120px;line-height: 120px"><b>上传失败请重新尝试</b></div>
            </div>
        </div>
    </div>
    <!--选择APP版本号-->
    <div id="appversionnumber" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="ture" style="border-radius: 8px;">
        <div class="modal-dialog" style="top:50%;margin-top:-100px">
            <div class="modal-content radius" style="height:222px;width:400px;">
                <div class="modal-header" style="border-bottom: none">
                    <a class="close" style="margin-right: 5px;width: 22px;height: 22px;margin-top: 5px" data-dismiss="modal" aria-hidden="true" >×</a>
                </div>
                <div class="mt-10 pl-30 clearfix" id="appversionnumbers">

                </div>
                <div class="mt-20 text-r" style="padding-right:164px;    margin-top: 101px;">
                    <input type="button" style="width: 96px;margin-left: 153px;" class="btn btn-secondary size-S radius ml-10" onclick="closeAll()" value="确定">
                </div>
            </div>
        </div>
    </div>

</article>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<script src="../../../../ht-js/frame/doT.min.js?rev=@@hash"></script>
<script src="../../../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../../../ht-js/Project.js?rev=@@hash"></script>
<script src="../../../../ht-js/operation-js/operation_activity/activity_login.js?rev=@@hash"></script>
<script src="../../../../ht-js/contract/jquery-form.js?rev=@@hash"></script>

<link type="text/css" rel="stylesheet" href="../../../../ht-js/operation-js/time-js/jedate.css">
<script type="text/javascript" src="../../../../ht-js/operation-js/time-js/jquery.jedate.js?rev=@@hash"></script>
<script>
    function returnVer(){
        layer.confirm('确认要取消吗？', {
            btn : [ '确定', '取消' ]//按钮
        }, function() {
            window.parent.search();
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
    }
    //添加最新android包弹窗
    function addAndroid() {
        $("#add-android").modal("show");
    }
    //关闭添加android包弹窗
    function closeSelect() {
        $("#add-android").modal("hide");
    }
    $(function () {
        //上传app安装包
        $('#uploadAppApk').click(function(){
            $("#uploadAppApk").attr("disabled","disabled");
            $('#appApkForm').ajaxSubmit({
                url:root.inter.imgUpload,
                type:"post",  //提交方式
                success:function (data) {
                    $("#uploadAppApk").attr("disabled",false);
                    if (data[0].errorCode == 0) {
                        $("#appApkPath").val(data[0].fullPath);
                        $.Huimodalalert('上传成功', 2000);

                        $("#appApkPathnames").html(data[0].fileName);
                      /*  $("#upload-success").modal("show");   //上传成功弹出*/
                        $("#add-android").modal("hide");
                    }else {
                        $("#appApkPath").val("");

                        $.Huimodalalert('上传失败请重新尝试', 2000);
                        $("#appApkPathnames").html("");
                        $("#add-android").modal("hide");
                       /* $("#upload-defate").modal("show");//上传失败弹出*/

                    }
                },
                error:function () {
                }
            })

            return false;
        })

    })


    //关闭弹框
    function closeAll() {
        console.log($('input:radio[name="appVersionCodes"]:checked').val())
        if($('input:radio[name="appVersionCodes"]:checked').val()!=undefined){
            $("#appversionnumber").modal("hide");
            $("#appVersionCoderadio").css({
                display: "inline"
            });
            $("#appVersionCoderadio").val($('input:radio[name="appVersionCodes"]:checked').val())
            $("#appVersionCode").html($('input:radio[name="appVersionCodes"]:checked').val())
        }else {
            layer.msg('请选择版本号', {icon: 5,time:2000});
        }

    }

//选择APP版本号
    function appversionnumber() {
        var appversionnumbers = ""
        $("#appversionnumber").modal("show");

        $.ajax({
            url: root.appversioncontrol.getAppVersionCodes,
            cache: false, //禁用缓存
            dataType: "json",
            data: {

            },
            success: function(data){

                for(var i = 0; i < data.data.length; i++) {
                    if($("#appVersionCoderadio").val()==""){
                        appversionnumbers += '<label><input type="radio" value="' + data.data[i] + '"  name="appVersionCodes"/>' + data.data[i] + '</label>&nbsp;&nbsp;'

                    }else {
                        if($("#appVersionCoderadio").val()==data.data[i]){
                            appversionnumbers += '<label><input type="radio" checked  value="' + data.data[i] + '"  name="appVersionCodes"/>' + data.data[i] + '</label>&nbsp;&nbsp;'

                        }else {
                            appversionnumbers += '<label><input type="radio" value="' + data.data[i] + '"  name="appVersionCodes"/>' + data.data[i] + '</label>&nbsp;&nbsp;'

                        }
                    }

                }

                $("#appversionnumbers").html(appversionnumbers)
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest);
            }
        });
    }




    //提交当前版本信息
    function save(){
        if($("#patchVersionCode").val()==""){
            layer.msg('补丁版本号不能为空！', {icon: 5,time:2000});
            return;
        }
        if($("#patchVersionName").val()==""){
            layer.msg('补丁包名称不能为空！', {icon: 5,time:2000});
            return;
        }
        if($("#appVersionCoderadio").val()==""){
            layer.msg('请选择版本号', {icon: 5,time:2000});
            return;
        }
        if($("#content").val()==""){
            layer.msg('请输入内容！', {icon: 5,time:2000});
            return;
        }
        if($("#status").val()==""){
            layer.msg('请选择状态！', {icon: 5,time:2000});
            return;
        }
        if($("#appApkPath").val()==""){
            layer.msg('请上传补丁包！', {icon: 5,time:2000});
            return;
        }

        $.ajax({
            url: root.appversioncontrol.checkPatchVersionCode,
            cache: false,  //禁用缓存
            type: "GET",
            dataType: "json",
            data: {
                "patchVersionCode": $("#patchVersionCode").val()
            },
            success: function(data){
             if (data.errorCode == 0){

            if(data.data==true){

            $.ajax({
            url: root.appversioncontrol.appversioncontrolsave,
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            contentType: "application/json",
            data: JSON.stringify({
                "patchVersionCode": $("#patchVersionCode").val(),
                "patchVersionName": $("#patchVersionName").val(),
                "appVersionCode": $("#appVersionCoderadio").val(),
                "content": $("#content").val(),
                "status": $("#status").val(),
                "filePath": $("#appApkPath").val(),
                "fileName":$("#appApkPathnames").html(),
                "createUser": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,

            }),
            success: function(data){
                if (data.errorCode == 0){
                    layer.msg("添加成功",{icon: 1,time:2000},function () {
                        setTimeout(function () {
                            window.parent.search();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        })
                    });
                }else {
                    layer.msg(data.msg, {icon: 5,time:2000});
                }
            },
            error:function(data){
                layer.msg(data, {icon: 5,time:2000});
            }
        });

         }else {
            layer.msg("版本号低，请重新输入", {icon: 5,time:2000});
          }

          }else {
            layer.msg(data.sub_msg, {icon: 5,time:2000});
          }
            },
            error:function(data){
                layer.msg(data, {icon: 5,time:2000});
            }
        });



    }
    //更新内容限制字符
    var len
    var Preser
    var common=200//要限制输入的字数
    function checkMaxIut(me) {
        var text=$(me).val()
        strlen(text)
        if(len>common){
            $(me).val(Preser)
        }else {
            Preser=$(me).val()
        }
    }
    function strlen(str){
        len = 0;
        for (var i=0; i<str.length; i++) {
            var c = str.charCodeAt(i);
            //单字节加1
            if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) {
                len++;
            } else {
                len+=2;
            }
        }
        return len;
    }
</script>
</body>
</html>